﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Framework_Tool
{
    /// <summary>
    /// Interaction logic for CourseDelete.xaml
    /// </summary>
    public partial class CourseDelete : Page
    {
        public CourseDelete()
        {
            InitializeComponent();
            Database.FindCourseID_Delete(this);
        }

        private void mainContent_Loaded_1(object sender, RoutedEventArgs e)
        {
            viewCourseBtn.FontWeight = FontWeights.Normal;
            addCourseBtn.FontWeight = FontWeights.Normal;
            updateCourseBtn.FontWeight = FontWeights.Normal;
            deleteCourseBtn.FontWeight = FontWeights.ExtraBold;
            searchCourseBtn.FontWeight = FontWeights.Normal;
        }

        private void viewCourseBtn_Click_1(object sender, RoutedEventArgs e)
        {
            
            CourseView crseViewWindow = new CourseView();
            crseViewWindow.Content = null;
            mainContent.Children.Add(crseViewWindow.mainContent);
        }

        private void updateCourseBtn_Click_1(object sender, RoutedEventArgs e)
        {
            CourseUpdate courseUpdateWindow = new CourseUpdate();
            courseUpdateWindow.Content = null;
            mainContent.Children.Add(courseUpdateWindow.mainContent);
        }

        private void addCourseBtn_Click_1(object sender, RoutedEventArgs e)
        {
            CourseAdd courseAddWindow = new CourseAdd();
            courseAddWindow.Content = null;
            mainContent.Children.Add(courseAddWindow.mainContent);
        }

        private void searchCourseBtn_Click_1(object sender, RoutedEventArgs e)
        {

        }

        private void crseDelete_Click_1(object sender, RoutedEventArgs e)
        {
            crseIDCmbx.SelectionChanged -= crseIDCmbx_SelectionChanged_1;
            Database.DeleteCourse(this);
            crseIDCmbx.SelectionChanged += crseIDCmbx_SelectionChanged_1;
        }

        private void cancelCrseDelete_Click_1(object sender, RoutedEventArgs e)
        {
            crseIDCmbx.SelectedItem = null;
            crseLeaderNameTxt_Delete.Text = null;
            crseTitleTxt.Text = null;
            crseDeletedLblGrid.Visibility = Visibility.Hidden;
            crseLevelTxt.Text = null;
            crseLeaderIDLbl.Content = null;
            crsePreReqTxt.Text = null;
        }

        private void crseIDCmbx_SelectionChanged_1(object sender, SelectionChangedEventArgs e)
        {
            Database.populateFields_CrseDelete(this);
        }
    }
}
